<template>
  <p-form-model :model="form" :rules="rules" layout="inline">
    <p-form-model-item label="线索编号">
      <p-input v-model="form.leadsNo" placeholder="请输入" />
    </p-form-model-item>
    <p-form-model-item label="线索名称">
      <p-input v-model="form.leadsName" placeholder="请输入" />
    </p-form-model-item>
    <p-form-model-item label="客户简称">
      <p-input v-model="form.customerShortName" placeholder="请输入" />
    </p-form-model-item>
    <p-form-model-item label="销售组织">
      <SelectOrg v-model="form.salesOrgCode" />
    </p-form-model-item>
    <p-button type="primary" class="btn-search" @click="handleSearch">
      搜索
    </p-button>
    <p-form-model-item label="当前状态">
      <SelectDefault v-model="form.currStatus" code="leads_create_status" />
    </p-form-model-item>
    <p-form-model-item label="当前节点">
      <SelectDefault v-model="form.nodeCode" code="leads_create_node" />
    </p-form-model-item>
    <p-form-model-item label="创建人">
      <p-input v-model="form.createUserName" placeholder="请输入" />
    </p-form-model-item>
    <p-form-model-item label="创建时间">
      <p-range-picker
        v-model="form.creatTime"
        :placeholder="['开始时间', '结束时间']"
        format="YYYY-MM-DD"
        :mode="mode"
        :value="value"
        @change="changeTime"
      />
    </p-form-model-item>
    <p-button @click="handleReset">重置</p-button>
  </p-form-model>
</template>
<script>
import monent from 'moment';
const defaultForm = {
  leadsNo: undefined,
  leadsName: undefined,
  customerShortName: undefined,
  salesOrgCode: undefined,
  currStatus: undefined,
  nodeCode: undefined,
  createUserName: undefined,
  creatTime: undefined,
  startCreateTime: undefined,
  endCreateTime: undefined,
};
export default {
  data() {
    return {
      form: {
        ...defaultForm,
        mode: ['date', 'date'],
        value: [],
      },
    };
  },
  methods: {
    handleSearch() {
      this.$emit('search', this.form);
    },
    handleReset() {
      this.form = { ...defaultForm };
      this.$emit('search', this.form);
    },
    changeTime(value) {
      this.value = value;
      this.form.startCreateTime =
        monent(value[0]).format('YYYY-MM-DD') + ' ' + '00:00:00';
      this.form.endCreateTime =
        monent(value[1]).format('YYYY-MM-DD') + ' ' + '23:59:59';
    },
  },
};
</script>

<style lang="less" scoped>
.poros-form {
  box-sizing: border-box;
  background-color: #f7f7f8;
  padding: 10px;
  padding-bottom: 0px;
  width: 100%;
}
.poros-form-item {
  width: 20%;
  margin-bottom: 10px;
}
/deep/ .poros-form-item-control-wrapper {
  width: calc(100% - 70px);
}
.btn-search {
  margin-right: 16px;
}
/deep/ .poros-form-item-label {
  width: 70px;
}
</style>
